package day26;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Receive {
    public static void main(String[] args) throws IOException {
        String receiveStr="";
        while(true){
            DatagramSocket ds = new DatagramSocket(1024);
            byte[] buf = new byte[1024];
            DatagramPacket dp = new DatagramPacket(buf, buf.length);
            ds.receive(dp);
            byte[] data = dp.getData();
            int port = dp.getPort();
            int len = data.length;
            InetAddress address = dp.getAddress();

            receiveStr = new String(data);
            System.out.println(address.getHostAddress() + ":" + receiveStr);
            ds.close();
        }
    }
}
